package com.totoro.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.totoro.dao.StudentDao;
import com.totoro.domain.Student;
import com.totoro.util.Page;

/**
 * 
 * @author zhangpeng
 * 
 * Student#Service层
 *
 */
@Transactional
@Service
public class StudentService {
	
	@Autowired
	private StudentDao studentDao;
	
	/**
	 * 查询所有学生信息
	 */
	public List<Student> findStudentByAll(){
		return studentDao.findAllStudent();
	}
	
	/**
	 * 分页测试方法：
	 */
	 public Page getPagedPosts(String name, Integer pageNo, int pageSize) {
		 return studentDao.getPagedPosts(name,pageNo,pageSize);
	}
	
	public List<Student> findStudentByName(String name){
		return studentDao.getStudentByName(name);
	}
	
	/**
	 * 添加学生信息
	 */
	public void addStudent(Student student){
		studentDao.save(student);
	}
	
	/**
	 * 删除学生信息
	 */
	public void deleteStudent(Student student){
		studentDao.delete(student);
	}
	
	/**
	 * 修改学生信息
	 */
	public void updateStudent(Student student){
		studentDao.update(student);
	}
	
	/**
	 * 根据id号查询学生信息
	 */
	public Student findStudentById(Integer id){
		return studentDao.findById(id);
	}
}
